using UnityEngine;

//允许通过其检查器设置其内容类型，并可以通过公共getter属性对其访问
[SelectionBase]//SelectionBase属性可以在场景窗口中强制选择内容根对象
public class GameTileContent : MonoBehaviour
{
    [SerializeField]
    GameTileContentType type = default;

    public GameTileContentType Type =>type;

    //跟踪工厂
    GameTileContentFactory originFactory;

    public GameTileContentFactory OriginFactory
    {
        get => originFactory;
        set{
            Debug.Assert(originFactory == null, "Redefined origin facotry!");
            originFactory = value;
        }
    }

    //判断是否阻塞路径，如果是墙壁或塔，则阻碍
    public bool BlocksPath => Type == GameTileContentType.Wall || Type == GameTileContentType.Tower;

    public virtual void GameUpdate()
    {

    }

    //回收
    public void Recycle()
    {
        originFactory.Reclaim(this);
    }
}